#include "treeservice.h"

TreeService::TreeService()
{

}

/**
 * @brief TreeService::initTreeData
 * 初始化树
 */
void TreeService::initTreeData()
{
    QString rootPath;
    rootPath.append("E:").append(QDir::separator()).append("图片");
    QDir root(rootPath);

    QFileInfoList localEntryInfoList = root.entryInfoList();
    QList<QFileInfo>::const_iterator it = localEntryInfoList.constBegin();
    for(;it != localEntryInfoList.constEnd();it++)
    {
        QFileInfo fileInfo = *it;

        QString path = fileInfo.filePath();
//        qDebug() << path;

        QTreeWidgetItem *item = new QTreeWidgetItem(tw);
        QIcon icon(":images/images/folder");
        item->setIcon(0,icon);
        item->setText(1,path);

        QDir father(path);
        int size = father.entryList().size();

        QString str;
        item->setText(2,str.setNum(size));

        tw->insertTopLevelItem(0,item);
    }

}
